﻿<%@ Page Title="Import contracts" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="Import.aspx.cs" Inherits="Presentation.AdminPresentation.Import" %>

<%@ Register Src="~/UserControl/Import.ascx" TagName="ImportForm" TagPrefix="uc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        function getChecked() {
            var list = $("input:checked");
            if (list.length == 0) {
                alert("You must choose atlease a contract!!");
                return false;
            }
            var control = document.getElementById('<%=ValueHidden.ClientID%>');
            control.setAttribute("value", "");
            var old;
            for (i = 0; i < list.length; i++) {
                old = control.getAttribute("value");
                control.setAttribute("value", old + list[i].id + "\n");
            }
            return true;
        }

        function errorDisplay() {
            var errorPanel = document.getElementById("ErrorPanel");
            var successPanel = document.getElementById("SuccessPanel");
            if (errorPanel.style.display == 'none') {
                errorPanel.style.display = "inline";
                successPanel.style.display = "none";
            } else {
                errorPanel.style.display = "none";
            }
        }

        function successDisplay() {
            var errorPanel = document.getElementById("ErrorPanel");
            var successPanel = document.getElementById("SuccessPanel");
            if (successPanel.style.display == 'none') {
                successPanel.style.display = "inline";
                errorPanel.style.display = "none";
            } else {
                successPanel.style.display = "none";
            }
        }

        function selectAll(control) {
            var list = $("input:checkbox");
            if (control.checked) {
                for (i = 0; i < list.length; i++) {
                    list[i].setAttribute("checked", "checked");
                }
            } else {
                for (i = 0; i < list.length; i++) {
                    list[i].removeAttribute("checked");
                }
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:HiddenField ID="ValueHidden" runat="server" />
    <div id="page-heading">
        <h1>
            <asp:Label ID="TitleLabel" runat="server" Text=""></asp:Label></h1>
    </div>
    <uc:ImportForm ID="ImportControl" runat="server" />
    <asp:Panel ID="ResultPanel" CssClass="resultPanel" runat="server" Visible="false">
        <asp:Label ID="ErrorText" ForeColor="Red" runat="server" />
        <br />
        <span onclick='successDisplay()' title='See success details' style='cursor: pointer;
            color: green'>
            <asp:Label ID="SuccessMessage" runat="server" />
        </span><span onclick='errorDisplay()' title='See error details' style='cursor: pointer;
            color: red'>
            <asp:Label ID="FailureMessage" runat="server" />
        </span>
        <div id='ErrorPanel' style='display: none; color: red'>
            <asp:Repeater ID="ErrorRepeater" runat="server">
                <ItemTemplate>
                    <div>
                        <%# Container.DataItem %></div>
                </ItemTemplate>
                <FooterTemplate>
                    <div>
                        <asp:Button ID="RegenerateButton" ToolTip="Export csv file" runat="server" CssClass="form-export"
                            OnClick="RegenerateButton_Click" /></div>
                </FooterTemplate>
            </asp:Repeater>
        </div>
        <div id='SuccessPanel' style='display: none; color: green'>
            <asp:Repeater ID="SuccessRepeater" runat="server">
                <ItemTemplate>
                    <div>
                        <%# Container.DataItem %></div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </asp:Panel>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Footer" runat="server">
</asp:Content>
